home *** CD-ROM | disk | FTP | other *** search
/ Gigantic Games 2 / Gigantic Games 2.iso / pc / _a_ / abitur / txt / intufrage.mod < prev    next >
Text File  |  1994-12-23  |  6KB  |  214 lines

  1. IMPLEMENTATION MODULE IntuFrage;
  2.  
  3. FROM Intuition IMPORT Gadget, BoolInfo, StringInfo, IntuiText,
  4.                       RefreshGadgets, IntuiMessage, IntuiMessagePtr,
  5.                       IDCMPFlagSet, IDCMPFlags,
  6.                       GadgetFlagSet, GadgetFlags,
  7.                       ActivationFlagSet, ActivationFlags,
  8.                       boolGadget, strGadget, boolMask,
  9.                       gadgHNone, ActivateGadget,
  10.                       ClearMenuStrip, SetMenuStrip, MenuPtr;
  11.  
  12. FROM Graphics  IMPORT Move, Text, DrawModes, DrawModeSet, SetAPen,
  13.                       Draw, FontStyleSet, FontStyles,
  14.                       AskSoftStyle, SetSoftStyle;
  15. FROM Exec      IMPORT WaitPort, GetMsg, ReplyMsg;
  16. FROM Fragen    IMPORT FragePtr, SchuelerAntwort;
  17. FROM AbiturScreen IMPORT BACKWindow, TafelPutz;
  18. FROM SYSTEM IMPORT ADR, ADDRESS, LONGSET;
  19. FROM Str IMPORT Length, Copy;
  20. FROM Arts IMPORT BreakPoint;
  21.  
  22.  
  23. VAR i          : INTEGER;
  24.     MyStrGadget: Gadget;
  25.     MyStrInfo  : StringInfo;
  26.     MyOKGadget : Gadget;
  27.     MyOKText   : IntuiText;
  28.     MyBoolGad  : ARRAY[1..6] OF Gadget;
  29.     StringBuffer,UndoBuffer: ARRAY[0..255] OF CHAR;
  30.  
  31.  
  32.  
  33. PROCEDURE IntuFrag(Fra: FragePtr; VAR Antw: SchuelerAntwort);
  34. (* Stellt die Frage Fra auf der Tafel,
  35.  * erwartete die Antwort in Antw.
  36.  * Nötigenfalls werden  die Gadgets abgefragt.
  37.  * Jedenfalls greifft die Procedur auf Abiturscreen zu
  38.  *)
  39. VAR IAddress (* , Adr *): ADDRESS;
  40.     imPtr: IntuiMessagePtr;
  41.     Class: IDCMPFlagSet;
  42.     AMaske, NMaske: FontStyleSet;
  43.     TempMenuPtr: MenuPtr;
  44. BEGIN
  45.    TafelPutz;
  46.    StringBuffer[0] := 0C;
  47.    BACKWindow^.firstGadget := ADR(MyStrGadget);
  48.    FOR i := 1 TO 6 DO
  49.       EXCL(MyBoolGad[i].flags, selected)
  50.    END;
  51.    RefreshGadgets(ADR(MyStrGadget), BACKWindow, NIL);
  52.    IF ActivateGadget(ADR(MyStrGadget), BACKWindow, NIL) THEN END;
  53.  
  54.    TempMenuPtr := BACKWindow^.menuStrip;
  55.    ClearMenuStrip(BACKWindow);
  56.  
  57.  
  58.   (* Kästchen um die Gadgets *)
  59.    SetAPen(BACKWindow^.rPort, 7);
  60.    FOR i := 1 TO 6 DO
  61.       Move(BACKWindow^.rPort, 161,  8 + 9*i);
  62.       Draw(BACKWindow^.rPort, 167,  8 + 9*i);
  63.       Draw(BACKWindow^.rPort, 167, 14 + 9*i);
  64.       Draw(BACKWindow^.rPort, 161, 14 + 9*i);
  65.       Draw(BACKWindow^.rPort, 161,  8 + 9*i)
  66.    END;
  67.  
  68.   (* Kasten um StringGadget *)
  69.    SetAPen(BACKWindow^.rPort, 7);
  70.    Move(BACKWindow^.rPort, 163, 83);
  71.    Draw(BACKWindow^.rPort, 277, 83);
  72.    Draw(BACKWindow^.rPort, 277, 94);
  73.    Draw(BACKWindow^.rPort, 163, 94);
  74.    Draw(BACKWindow^.rPort, 163, 83);
  75.  
  76.   (* Kasten um OK Gadget *)
  77.    SetAPen(BACKWindow^.rPort, 7);
  78.    Move(BACKWindow^.rPort, 296     , 83);
  79.    Draw(BACKWindow^.rPort, 296 + 18, 83);
  80.    Draw(BACKWindow^.rPort, 296 + 18, 94);
  81.    Draw(BACKWindow^.rPort, 296     , 94);
  82.    Draw(BACKWindow^.rPort, 296     , 83);
  83.  
  84.    SetAPen(BACKWindow^.rPort, 1);
  85.    AMaske := AskSoftStyle(BACKWindow^.rPort);
  86.    NMaske := SetSoftStyle(BACKWindow^.rPort, FontStyleSet{italic}, AMaske);
  87.    FOR i := 0 TO 10 DO
  88.       Fra^.Txt[i][18] := 0C;
  89.       Move(BACKWindow^.rPort, 6, 23 + 9 * i);
  90.       Text(BACKWindow^.rPort, ADR(Fra^.Txt[i]), Length(Fra^.Txt[i]))
  91.    END;
  92.    SetAPen(BACKWindow^.rPort, 7);
  93.    NMaske := SetSoftStyle(BACKWindow^.rPort, FontStyleSet{}, AMaske);
  94.    FOR i := 1 TO 6 DO
  95.       Fra^.MultipleAntw[i][18] := 0C;
  96.       Move(BACKWindow^.rPort, 170, 14 + 9 * i);
  97.       Text(BACKWindow^.rPort, ADR(Fra^.MultipleAntw[i]),
  98.                               Length(Fra^.MultipleAntw[i]))
  99.    END;
  100.    REPEAT
  101.       WaitPort(BACKWindow^.userPort);
  102.       imPtr := GetMsg(BACKWindow^.userPort);
  103.       Class := imPtr^.class;
  104.       IAddress := imPtr^.iAddress;
  105.       ReplyMsg(imPtr);
  106.       (* BreakPoint(ADR("In WaitLoop")) *)
  107.    UNTIL (gadgetUp IN Class)
  108.       AND ((IAddress = ADR(MyOKGadget)) OR (IAddress = ADR(MyStrGadget)));
  109.  
  110.   (* BELEGEN *)
  111.    Copy(Antw.Str, StringBuffer);
  112.    Antw.Mul := {};
  113.    FOR i := 1 TO 6 DO
  114.       IF selected IN MyBoolGad[i].flags THEN
  115.          INCL(Antw.Mul, i-1)
  116.       END
  117.    END;
  118.  
  119.    IF SetMenuStrip(BACKWindow, TempMenuPtr) THEN END;
  120.  
  121.  
  122.  
  123.    BACKWindow^.firstGadget := NIL;
  124.    RefreshGadgets(NIL, BACKWindow, NIL);
  125.    TafelPutz
  126. END IntuFrag;
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. BEGIN (* IntuFrage InitialisationsTeil *)
  134.    StringBuffer[0] := 0C;
  135.    WITH MyStrInfo DO
  136.       undoBuffer := ADR(UndoBuffer);
  137.       buffer := ADR(StringBuffer);
  138.       numChars := Length(StringBuffer);
  139.       bufferPos := 0; maxChars := 64;
  140.       dispPos := 0; undoPos := 0;
  141.       dispCount := 0; cLeft := 0; cTop := 0;
  142.       layerPtr := NIL; longInt := 0; altKeyMap := NIL
  143.    END;
  144.    WITH MyStrGadget DO
  145.       nextGadget := ADR(MyOKGadget);
  146.       leftEdge := 164;
  147.       topEdge := 85;
  148.       width := 115;
  149.       height :=10;
  150.       flags := GadgetFlagSet{selected};
  151.       activation := ActivationFlagSet{relVerify, endGadget, stringCenter};
  152.       gadgetType := strGadget;
  153.       gadgetRender := NIL;
  154.       selectRender := NIL;
  155.       gadgetText := NIL;
  156.       mutualExclude := LONGSET{};
  157.       specialInfo := ADR(MyStrInfo);
  158.       gadgetID := 1;
  159.       userData := NIL
  160.    END; (* WITH StrGadg *)
  161.    WITH MyOKText DO
  162.       frontPen := 5;
  163.       backPen := 4;
  164.       drawMode := DrawModeSet{};
  165.       leftEdge := 1;
  166.       topEdge := 1;
  167.       iTextFont := NIL;
  168.       iText := ADR("OK");
  169.       nextText := NIL
  170.    END;
  171.    WITH MyOKGadget DO
  172.       nextGadget := ADR(MyBoolGad[1]);
  173.       leftEdge := 297;
  174.       topEdge := 84;
  175.       width := 17;
  176.       height := 10;
  177.       flags := GadgetFlagSet{}; (* Complement *)
  178.       activation := ActivationFlagSet{gadgImmediate, relVerify};
  179.       gadgetType := boolGadget;
  180.       gadgetRender := NIL;
  181.       selectRender := NIL;
  182.       gadgetText := ADR(MyOKText);
  183.       mutualExclude := LONGSET{};
  184.       specialInfo := NIL;
  185.       gadgetID := 2;
  186.       userData := NIL
  187.    END; (* WITH OKGadg *)
  188.    FOR i := 1 TO 6 DO
  189.       WITH MyBoolGad[i] DO
  190.          IF i # 6 THEN
  191.             nextGadget := ADR(MyBoolGad[i+1])
  192.          ELSE (* Letztes GAdget hat keinen Nachfolger *)
  193.             nextGadget := NIL
  194.          END;
  195.          leftEdge := 162;
  196.          topEdge  := 9*i + 9;
  197.          width := 5;
  198.          height := 5;
  199.          flags := GadgetFlagSet{}; (* Complement *)
  200.          activation := ActivationFlagSet
  201.                        { relVerify, gadgImmediate, toggleSelect};
  202.          gadgetType := boolGadget;
  203.          gadgetRender := NIL;
  204.          selectRender := NIL;
  205.          gadgetText := NIL;
  206.          mutualExclude := LONGSET{};
  207.          specialInfo := NIL;
  208.          gadgetID := i + 2;
  209.          userData := NIL
  210.       END (* WITH BoolGadgs*)
  211.    END
  212. END IntuFrage.
  213.  
  214.